package com.cho.core.util;

import java.util.HashSet;
import java.util.Set;

import com.cho.core.CustomProgramFileExtensionFilter;

public class StringUtils {
	public static boolean isNotEmpty(String str){
		return !isEmpty(str);
	}
	
	public static boolean isEmpty(String str){
		if(str == null || str.trim().length() < 1){
			return true;
		}else{
			return false;
		}
	}
	
	public static String removeParenthesis(String str){
		if(isEmpty(str)){
			return str;
		}else{
			return str.replace("(", "").replace(")", "");
		}
	}
	
	public static String nvl(String str, String nvlTo){
		if(isEmpty(str)){
			return nvlTo;
		}else{
			return str;
		}
	}
	
	public static String extractFileExtention(String filePath){
		return nvl(filePath.substring(filePath.lastIndexOf(".") + 1, filePath.length()), "");
	}
	
	public static boolean isSqlFile(String filePath){
		boolean isSqlFile = false;
		Set<String> SqlFileExtensionSet = CustomProgramFileExtensionFilter.getSqlFileExtensionSet();
		
		for (String currentSqlFileExtension : SqlFileExtensionSet) {
			if(currentSqlFileExtension.equals(extractFileExtention(filePath))){
				isSqlFile = true;
				break;
			}
		}
		
		return isSqlFile;
	}
}
